﻿using System.Collections.Generic;
using System.Linq;
using ICore;
using EntityFrameWorkAccess;
using System.Data;

namespace Service
{
    public class DinnerService : RepositoryBase<Dinner>, IDinnerService
    {
        /// <summary>
        ///   通过分类<seealso cref="ICore.Category"/>的ID获取该分类的Dinner集合
        /// </summary>
        /// <param name="categoryId"></param>
        /// <returns></returns>
        public IList<Dinner> GetDinnersByCategory(long categoryId)
        {
            using (var db = new DinnerContext())
            {
                return db.Categories.Where(c => c.ID == categoryId).SingleOrDefault().Dinners;
            }
        }
    }
}
